package com.appbee.gdata.picasa.client;

import javax.inject.Inject;

import com.appbee.core.client.modular.IModulRegistry;
import com.appbee.core.client.modular.SettingsView;
import com.appbee.core.client.modular.impl.ActivityModul;
import com.appbee.gdata.picasa.client.activity.PicasaPhotoShowActivity;
import com.appbee.gdata.picasa.client.ui.PhotoShowSettingsView;
import com.google.gwt.inject.client.AsyncProvider;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class PicasaPhotoShowActivityModul extends ActivityModul
{
	private static final String ID = "picasaPhotosShow";
	private final AsyncProvider<PicasaPhotoShowActivity> activityProvider;
	private final IModulRegistry registry;
	private final AsyncProvider<PhotoShowSettingsView> settingsViewProvider;

	@Inject
	public PicasaPhotoShowActivityModul(AsyncProvider<PicasaPhotoShowActivity> activityProvider,
										AsyncProvider<PhotoShowSettingsView> settingsViewProvider,
										IModulRegistry registry)
	{
		setDefaultActivty(activityProvider);
		this.activityProvider = activityProvider;
		this.settingsViewProvider = settingsViewProvider;
		this.registry = registry;
	}

	@Override
	public String getName()
	{
		return "Picasa Photoshow";
	}

	public void register()
	{
		register(ID, activityProvider);
		registry.register(ID, this);
	}

	@Override
	public String getId()
	{
		return ID;
	}

	@Override
	public void getSettingsView(final AsyncCallback<SettingsView> callback)
	{
		settingsViewProvider.get(new AsyncCallback<PhotoShowSettingsView>()
		{

			@Override
			public void onSuccess(PhotoShowSettingsView result)
			{
				callback.onSuccess(result);
			}

			@Override
			public void onFailure(Throwable caught)
			{
				callback.onFailure(caught);
			}
		});
	}

}
